<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>回调ref的问题</title>
</head>
<body>
  <div id="app"></div>
  <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
  <script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
  <!-- 生产环境中不建议使用 -->
  <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.7.2/prop-types.min.js"></script>

  <script type="text/babel">
    class Demo extends React.Component {
      state = {
        isHost: false
      }
      handleClick = () => {
        const { input1 } = this
        console.log(input1.value)
      }
      changeWeather = () => {
        const { isHost } = this.state
        this.setState({
          isHost: !isHost
        })
      }
      saveInput = (c) => {
        this.input1 = c
        console.log(c)
      }
      render() {
        const { isHost } = this.state
        return (
          <div>
            <h2 onClick={this.changeWeather}>今天天气很{isHost ? '炎热' : '凉爽'}</h2>
            
            {/* <input ref={c => {this.input1 = c;console.log('@',c)}} type="text" /> */}
            <input ref={this.saveInput} type="text" />
            <button onClick={this.handleClick}>点我提示左侧数据</button>
          </div>
        )
      }
    }
    ReactDOM.render(<Demo />, document.getElementById('app'))
  </script>
</body>
</html>